#pragma once

#include "Common.h"

// 单例模式
class CentralCache
{
public:
    static CentralCache *GetInstance()
    {
        return &_sInst;
    }
    // zdl:: 得到一个非空的 span
    size_t FetchRangeObj(void *&start, void *&end, size_t n, size_t size);
    // zdl:: 从中心的缓存获取一定数量的对象给 central cache
    Span *GetOneSpan(SpanList &list, size_t size);
    // zdl:: 将一定数量的对象释放的span跨度
    void ReleaseListToSpans(void *start, size_t byte_size);

private:
    CentralCache()
    {
    }
    CentralCache(const CentralCache &) = delete;
    SpanList _spanLists[NFREE_LIST];

    static CentralCache _sInst;
};